package com.holyn.guofang.viewcommon.activity;

import android.app.Activity;
import android.content.Intent;
import android.view.View;

import com.bumptech.glide.Glide;
import com.holyn.guofang.R;
import com.holyn.guofang.view.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Holyn on 2017/6/1.
 */

public class ImagePreviewActivity extends BaseActivity {
    private static final String INTENT_KEY_IMG_URL = "INTENT_KEY_IMG_URL";

    @BindView(R.id.piv)
    PinchImageView piv;

    private String imgUrl;

    public static void start(Activity fromActivity, String imgUrl){
        Intent intent = new Intent(fromActivity, ImagePreviewActivity.class);
        intent.putExtra(INTENT_KEY_IMG_URL, imgUrl);
        fromActivity.startActivity(intent);
    }

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_image_preview;
    }

    @Override
    protected void onMyCreate() {
        ButterKnife.bind(this);

        imgUrl = getIntent().getStringExtra(INTENT_KEY_IMG_URL);
//        showToolbar(imgUrl.substring(imgUrl.lastIndexOf("/")+1));

        Glide.with(ImagePreviewActivity.this)
                .load(imgUrl)
//                .error(R.drawable.ic_empty_image)
                .into(piv);

        piv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ImagePreviewActivity.this.finish();
            }
        });

    }
}
